package 作业;

public class homework03_28 {

    private static int sum1;
    private static int sum2;
    public int sumArray(int[] arr){
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < arr.length; i++) {
                    if(i % 2 == 0){
                        sum1 += arr[i];
                    }
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < arr.length; i++) {
                    if(i % 2 != 0){
                        sum2 += arr[i];
                    }
                }
            }
        });
        return sum1 + sum2;
    }
}
